import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)

const originalPush = Router.prototype.push
Router.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
  return originalPush.call(this, location).catch(err => err)
}

export default new Router({
  mode: 'history',
  routes: [
    {
      path: '/index',
      name: 'Index',
      component: () => import('@/views/Index'),
      redirect: '/first',
      children: [
        {
          path: '/first',
          name: 'First',
          component:() => import('@/views/First'),
        },{
          path: '/recreation',
          name: 'Recreation',
          component:() => import('@/views/Recreation'),
        },{
          path: '/game',
          name: 'Game',
          component:() => import('@/views/Game'),
        },{
          path: '/sport',
          name: 'Sport',
          component:() => import('@/views/Sport'),
        },{
          path: '/car',
          name: 'Car',
          component:() => import('@/views/Car'),
        },{
          path: '/select',
          name: 'Select',
          component:() => import('@/views/Select'),
        },{
          path: '/video',
          name: 'Video',
          component:() => import('@/views/Video'),
        }
      ]
    },{
      path: '/',
      redirect:'/index',
    },{
      path: '/login',
      name: 'Login',
      component: () => import('@/views/Login'),
    },{
      path: '/register',
      name: 'Register',
      component: () => import('@/views/Register'),
    },{
      path: '/toAdmin',
      name: 'ALogin',
      component: () => import('@/views/admin/Login'),
    },{
      path: '/admin',
      name: 'Admin',
      component: () => import('@/views/admin/Admin'),
      children:[
        {
          path: '/user',
          name: 'User',
          component: () => import('@/views/admin/UserAdmin'),
        },{
          path: '/role',
          name: 'Role',
          component: () => import('@/views/admin/RoleAdmin'),
        },{
          path: '/infor',
          name: 'Infor',
          component: () => import('@/views/admin/InforAdmin'),
        },{
          path: '/classify',
          name: 'Classify',
          component: () => import('@/views/admin/ClassifyAdmin'),
        }

      ]
    }
  ]
})
